﻿@page "/table/export"
@inject IStringLocalizer<TablesExport> Localizer
@inject IStringLocalizer<Foo> LocalizerFoo
@inject ToastService ToastService

<h3>@Localizer["TablesExportTitle"]</h3>
<h4>@((MarkupString)Localizer["TablesExportDescription1"].Value)</h4>

<p>@((MarkupString)@Localizer["TablesExportDescription2"].Value)</p>

<PackageTips Name="BootstrapBlazor.TableExport" />

<p class="mt-3"><b>@Localizer["TablesExportTips"]：</b></p>

<Pre>public void ConfigureServices(IServiceCollection services)
{
    // @Localizer["TablesExportNote1"]
    services.AddBootstrapBlazor();

    // @Localizer["TablesExportNote2"]
    services.AddBootstrapBlazorTableExcelExport();
}</Pre>

<DemoBlock Title="@Localizer["TablesExportShowExportButtonTitle"]"
           Introduction="@Localizer["TablesExportShowExportButtonIntro"]"
           Name="ShowExportButton">
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" IsMultipleSelect="true"
           ShowToolbar="true" ShowDefaultButtons="false" ShowExportButton="true"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["TablesExportShowExportCsvButtonTitle"]"
           Introduction="@Localizer["TablesExportShowExportCsvButtonIntro"]"
           Name="ShowCsvExportButton">
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" IsMultipleSelect="true"
           ShowToolbar="true" ShowDefaultButtons="false"
           ShowExportButton="true" ShowExportCsvButton="true" ShowExportPdfButton="true"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["TablesExportOnExportAsyncTitle"]"
           Introduction="@Localizer["TablesExportOnExportAsyncIntro"]"
           Name="OnExportAsync">
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" IsMultipleSelect="true"
           ShowToolbar="true" ShowDefaultButtons="false" ShowExportButton="true"
           OnExportAsync="OnExportAsync" OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["TablesExportButtonDropdownTemplateTitle"]"
           Introduction="@Localizer["TablesExportButtonDropdownTemplateIntro"]"
           Name="ExportButtonDropdownTemplate">
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" IsMultipleSelect="true"
           ShowToolbar="true" ShowDefaultButtons="false" ShowExportButton="true"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
        <ExportButtonDropdownTemplate Context="ExportContext">
            <div class="dropdown-item" @onclick="() => ExcelExportAsync(ExportContext)">
                <i class="fa-regular fa-file-excel"></i>
                <span>@Localizer["TablesExportButtonExcelText"]</span>
            </div>
            <div class="dropdown-item" @onclick="() => ExcelExportAllAsync(ExportContext)">
                <i class="fa-regular fa-file-excel"></i>
                <span>@Localizer["TablesExportButtonExcelAllText"]</span>
            </div>
            <div class="dropdown-item" @onclick="() => CsvExportAsync(ExportContext)">
                <i class="fa-regular fa-file-excel"></i>
                <span>MS-CSV</span>
            </div>
            <div class="dropdown-item" @onclick="() => ClipBoardExportAsync(ExportContext)">
                <i class="fa-regular fa-file-excel"></i>
                <span>@Localizer["TablesExportButtonCliBoardText"]</span>
            </div>
            <div class="dropdown-item" @onclick="() => ClipBoardExportAllAsync(ExportContext)">
                <i class="fa-regular fa-file-excel"></i>
                <span>@Localizer["TablesExportButtonCliBoardAllText"]</span>
            </div>
        </ExportButtonDropdownTemplate>
    </Table>
</DemoBlock>
